class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        // write code here
        stack<int> st;
        for (int i = 0; i < tokens.size(); ++i)
        {
            if (tokens[i] == "+" || tokens[i] == "-" || tokens[i] == "*" || tokens[i] == "/")
            {
                int right = st.top();
                st.pop();
                int left = st.top();
                st.pop();
                if (tokens[i] == "+") st.push(left + right);
                else if (tokens[i] == "-") st.push(left - right);
                else if (tokens[i] == "*") st.push(left * right);
                else if (tokens[i] == "/") st.push(left / right);
            }
            else
            {
                int n = stoi(tokens[i]);
                st.push(n);
            }
        }
        int res = st.top();
        return res;
    }
};